@extends('layouts.app')

@section('content')
<div class="content import_detail {{$order->status ? 'handel_shipped' : 'handel_unship' }}">
	<div class="button">
		<a href="javascript:history.go(-1);location.replace(document.referrer);">＜返回</a>
	</div>
	<p>当前订单状态：<b>{{$order->status ? "已发货" : "待发货"}}</b></p>
	<div class="msg user_msg">
		<h4><b>查看用户</b></h4>
		<ul>
			<li><span>受赠者六度账号：</span>{{$order->phone}}</li>
			<li><span>赠送者六度账号：</span>{{$order->sendLog->order->phone}}</li>
		</ul>
	</div>
	<div class="msg order_msg">
		<h4><b>订单信息</b></h4>
		<ul>
			<li><span>订单号：</span>{{$order->order_id}}</li>
			<li><span>商品：</span>{{$order->products}}</li>
			<li><span>下单时间：</span>{{$order->created_at}}</li>
		</ul>
	</div>
	<div class="msg receipt_msg">
		<h4><b>收货信息</b></h4>
		<ul>
			<li><span>联系人：</span>{{$order->contacts}}</li>
			<li><span>手机号：</span>{{$order->phone}}</li>
			<li><span>收获地址：</span>{{$order->receipt_area}}</li>
		</ul>
		<p><span>详细地址：</span>{{$order->receipt_address}}</p>
	</div>
	<div class="msg other_msg">
		<h4><b>物流信息</b></h4>
		<ul>
			@if($order->status)
				<li><span><i>*</i>运单号码：</span>{{$order->ship_num}}</li>
				<li><span><i>*</i>物流公司：</span>{{$order->ship_company}}</li>
				<li><span><i>*</i>邮费：</span>{{$order->decimal}}元</li>
			@else
				<li><span><i>*</i>运单号码：</span><input type="text" id="ship_num" placeholder="请输入运单号码"></li>
				<li><span><i>*</i>物流公司：</span><input type="text" id="ship_company" placeholder="请输入物流公司名称"></li>
				<li><span><i>*</i>邮费：</span><input type="number" id="decimal" placeholder="请输入邮费"></li>
				<li class="button"><button onclick="shipOrder({{$order->id}})">确定发货</button></li>
			@endif
		</ul>
	</div>
</div>
@endsection


@section('scripts')
<script type="text/javascript">
	function shipOrder(id) {
		var form = new Object();
		form.ship_num = $('#ship_num').val();
		form.ship_company = $('#ship_company').val();
		form.decimal = $('#decimal').val();
		if(form.ship_num == undefined || form.ship_num == '') {
			box.tipHover({ status: 0, msg: "请输入运单号码" });
			// alert('请输入运单号码');
			return false;
		}
		if(form.ship_num == undefined || form.ship_num == '') {
			box.tipHover({ status: 0, msg: "请输入物流公司" });
			// alert('请输入物流公司');
			return false;
		}
		if(form.ship_num == undefined || form.ship_num == '') {
			box.tipHover({ status: 0, msg: "请输入邮费" });
			// alert('请输入邮费');
			return false;
		}

		$.ajax({
			type: "POST",
			url: "/sendOrder/ship/"+id,
			dataType: "json",
			data: form,
			success: function(res) {
				location.reload();
			}
		});
	}
</script>
@endsection
